home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 22 / PC Actual CD 22.iso / SHARE / prog / POVRAY / SPRAY.ZIP / SPRAYG.INC < prev    next >
Encoding:
Text File  |  1997-05-23  |  4.5 KB  |  86 lines

  1. // *******************************************************
  2. // LIQUID SPRAY INCLUDE FILE FOR PERSISTENCE OF VISION 3.x
  3. // *******************************************************
  4. //
  5. // Created by Chris Colefax, 23 May 1997
  6. //
  7. // See "Spray.txt" for more information.
  8. // NOTE: This file should not be included directly in a POVRay scene!
  9. //
  10. // *******************************************************
  11.  
  12. // ROTATE VECTORS IF SKY IS NOT +Y
  13. // *******************************
  14.    #if (_SP_sky.y != 1)
  15.       #declare _SP_idisp = vrotate(vrotate(_SP_idisp, -y * _SP_wroty), -x * _SP_wrotx)
  16.       #declare _SP_ivel  = vrotate(vrotate(_SP_ivel,  -y * _SP_wroty), -x * _SP_wrotx)
  17.       #declare _SP_wind  = vrotate(vrotate(_SP_wind,  -y * _SP_wroty), -x * _SP_wrotx)
  18.    #end
  19.  
  20. // SHIFT IF GROUND DISTANCE IS NOT 0
  21. // *********************************
  22.    #if (ground_dist != 0) #declare _SP_idisp = _SP_idisp - y * ground_dist #end
  23.  
  24. // CALCULATE ACCELERATION, CURRENT VELOCITY, DISPLACEMENT
  25. // ******************************************************
  26.    #if (vlength(_SP_wind) > 0) #declare _SP_accel = _SP_accel + vrotate(_SP_wind * _SP_pscale.z / _SP_psize.z, (<_SP_rand1, _SP_rand2, _SP_rand3> - .5) * 360 * _SP_wturb) #end
  27.    #declare _SP_cclk  = _SP_time
  28.    #declare _SP_iclk  = 0 #declare _SP_bounces = 0
  29.    #declare _SP_cvel  = _SP_ivel + (_SP_accel * _SP_cclk)
  30.    #declare _SP_cdisp = _SP_idisp + (_SP_ivel * _SP_cclk) + (.5 * _SP_accel * _SP_cclk * _SP_cclk)
  31.    #while (_SP_cdisp.y < 0)
  32.  
  33. // CALCULATE TIME OF INTERSECTION WITH GROUND PLANE
  34. // ************************************************
  35.    #if (_SP_accel.y = 0) #declare _SP_iclk = _SP_idisp.y / -_SP_ivel.y
  36.       #else #declare _SP_iclk = (-_SP_ivel.y - sqrt (_SP_ivel.y * _SP_ivel.y - (2 * _SP_accel.y * _SP_idisp.y))) / _SP_accel.y #end
  37.  
  38.    #declare _SP_idisp = _SP_idisp + (_SP_ivel * _SP_iclk) + (.5 * _SP_accel * _SP_iclk * _SP_iclk)
  39.    #declare _SP_ivel  = (_SP_ivel + (_SP_grav * _SP_iclk)) * <1, -ground_reflection, 1>
  40.    #declare _SP_cclk = _SP_cclk - _SP_iclk
  41.  
  42. // CHECK IF PARTICLE HAS STOPPED MOVING
  43. // ************************************
  44.    #if (ground_reflection = 0 | _SP_bounces >= max_bounces)
  45.       #if (ground_friction = 0) #declare _SP_cdisp = _SP_idisp
  46.          #else #if (ground_friction = 1) #declare _SP_cdisp = _SP_idisp + (_SP_ivel * _SP_cclk)
  47.          #else #declare _SP_cdisp = _SP_idisp + (_SP_ivel * ((pow(ground_friction, _SP_cclk) / log(ground_friction)) - (1 / log(ground_friction)))) #end #end
  48.       #declare _SP_cdisp = _SP_cdisp * <1, 0, 1>
  49.       #declare _SP_cvel  = _SP_ivel
  50.    #else
  51.       #declare _SP_cvel  = _SP_ivel + (_SP_accel * _SP_cclk)
  52.       #declare _SP_cdisp = _SP_idisp + (_SP_ivel * _SP_cclk) + (.5 * _SP_accel * _SP_cclk * _SP_cclk)
  53.    #end #declare _SP_bounces = _SP_bounces + 1 #end
  54.  
  55. // CREATE PARTICLE
  56. // ***************
  57.    #if (_SP_bounces > max_bounces & puddle_thickness <= 0)
  58.       sphere {x * _SP_count, 0 #if (use_blob != false) , 0 #end }
  59.    #else
  60.       #declare _SP_protate = <-degrees (atan2 (_SP_cvel.y, vlength (_SP_cvel * <1,0,1>))), degrees (atan2 (_SP_cvel.x, _SP_cvel.z)), 0>
  61.       #if (evaporate != 0) #declare _SP_psize = _SP_psize * (pow(1 - (_SP_time / _SP_tscale / _SP_plife), evaporate) + .01) #end
  62.  
  63.       sphere {<0, 0, 0>, 1 #if (use_blob != false) , 1 #end
  64.       #if (use_color_map = false)
  65.          #if (components_only != false & use_blob != false)
  66.             texture {spray_texture} #end
  67.       #else texture {spray_texture
  68.          pigment {gradient z color_map {spray_color_map} triangle_wave
  69.             translate (color_map_triangle = false ? .5 : 1) * (spray_loop = false ? _SP_pclock * color_map_frequency / _SP_duration : mod(_SP_pclock * color_map_frequency, _SP_plife) / _SP_plife) + ((_SP_rand3 - .5) * _SP_cturb)
  70.             scale _SP_psize * 1000}} #end
  71.          scale _SP_psize rotate _SP_protate translate y * _SP_cdisp
  72.       #declare _SP_pdist = _SP_cdisp.y / ((_SP_psize.x + _SP_psize.y + _SP_psize.z) / 3)
  73.       #if (_SP_pdist < 1)
  74.          #declare _SP_pthick = (_SP_pdist < puddle_thickness ? puddle_thickness : _SP_pdist)
  75.          scale ((y * _SP_pthick) + (<1, 0, 1> / sqrt(_SP_pthick))) * (1 + ((puddle_scale - 1) * (1 - _SP_pthick)))
  76.       #end
  77.       translate <1, 0, 1> * _SP_cdisp
  78.  
  79. // UNDO GROUND DISTANCE SHIFT AND SKY VECTOR ROTATION
  80. // **************************************************
  81.    #if (ground_dist != 0) translate y * ground_dist        #end
  82.    #if (_SP_sky.y != 1)   rotate <_SP_wrotx, _SP_wroty, 0> #end
  83.    }
  84.  
  85.    #end
  86.